<template>
  <div>
    <el-button @click="add"
    type="success" 
    icon="el-icon-circle-plus-outline">
    新增
    </el-button>
    <list @edit='doedit' ref="list"></list>
    <info :info='info' @update='update' ref="info"></info>
  </div>
</template>

<script>
import list from "./list.vue";
import info from "./info.vue";
export default {
  data(){
    return{
      info:{
        isShow:false,
        type:'add'
      }
      
    }
  },
  components: {
    list,
    info,
  },
  methods:{
    add(){
      this.info.isShow=true;
      this.info.type='add';
      this.$refs.info.setValue({
        // 上级id，可能会重复，id不会重复
        pid: 0,
        title: "",
        icon: "",
        // 一级叫目录，二级叫菜单
        type: 1,
        url: "",
        status: 1,
      })
    },
    doedit(edit){
      this.info.isShow=true;
      this.info.type='edit';
      this.$refs.info.setValue(edit)
    },
    update(){
      this.$refs.list.getMenu()
    }
  }
};
</script>
<style scoped>
</style>